<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<% 
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<jsp:include page="checkAdmin.jsp" />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   <link href="css/style.css" rel="stylesheet" type="text/css" />
   <link rel="stylesheet" type="text/css" href="css/smoothness/jquery-ui.css" />
   <script type="text/javascript" src="js/jquery-2.0.js"></script>
   <script type="text/javascript" src="js/jquery-ui.js"></script>
   <script type="text/javascript" src="js/jquery.form.js"></script>

<script type="text/javascript">
    $(document).ready(function () {
   		
   			$('#loading').dialog({
				height:50,
				width:180,
				autoOpen:false,
				modal:true,
				closeOnEscape:false,
				resizable:false,
				
			}).parent().find('.ui-widget-header').hide();
   		
   		

	   	 var options = {
	   	 	url:'student-addGroup.action',
			type:'POST',
		   	beforeSend:function(){
				$('#loading').dialog('open');
				$('#loading').css('background','url(images/loading.gif) no-repeat 20px center').html("数据交互中...");
			},
	        success: function (data,textStatus) {
	        
	           if(data=="success"){
				
				$('#loading').css('background','url(images/success.gif) no-repeat 20px center').html("数据保存成功...");
				setTimeout(function(){
					$('#loading').dialog('close'); 
					$('#loading').css('background','url(images/loading.gif) no-repeat 20px center').html("数据交互中...");
					
				},1000);
				
				//跳转
				setTimeout(function(){
					window.location.href="student-listGroup.action";
				},800);
				
			}else{
				$('#loading').css('background','url(images/error.png) no-repeat 20px center').html("数据保存失败...");
				setTimeout(function(){
					$('#loading').dialog('close'); 
					$('#loading').css('background','url(images/loading.gif) no-repeat 20px center').html("数据交互中...");
					
				},1000);
			 }
	      	}
	     };
    

   			$(".btn").click(function(){
   				//验证表单
   			      var fm = $("#GroupSaveForm");
   			      
   			      if($.trim($('input[name=gname]').val().length)==0){
   			      	$(".g_error").html("分组名称不能为空!");
   			      	return false;
   			      }
   			      if($.trim($('input[name=gname]').val().length)>50){
   			      	$(".g_error").html("分组名称不能超过50个字符!");
   			      	return false;
   			      }
   			      
   				 fm.ajaxSubmit(options);
   				 return false;
   			});
   
   		
   		});
   		
   </script>
</head>

<body>

<div id="loading"></div>
	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="index.jsp">首页</a></li>
    <li><a href="student-listGroup.action">分组管理</a></li>
    <li><a href="#">创建分组</a></li>
    </ul>
    </div>
    
    <div class="formbody">
    <div class="formtitle"><span>创建分组</span></div>
	   <form id="GroupSaveForm">
	    <ul class="forminfo">
	    <li><p style="color:red" class="g_error"></p></li>
	    <li><label>分组名称</label><input name="gname" type="text" class="dfinput" /><i>分组名称不得大于50个字符</i></li>
	    <li><label>所属用户</label><input  type="text" readonly="readonly" class="dfinput" value="${sessionScope.admin}"/></li>
	    <li><label>&nbsp;</label><input  type="button" class="btn" value="确认保存"/></li>
	    </ul>
	    </form>
    </div>
</body>
</html>
